b='/home/wangdy/MNVTFdb/Server/Services/Predict/tmp'
a='/home/wangdy/MNVTFdb/Server/Services/Predict'

# $a/scripts/fimo --norc --text --verbosity 1 --no-qvalue $a/pwm/HOCOMOCOv11_core_HUMAN_mono_meme_format.meme $b/$1/$1.ref.fa >$b/$1/$1.ref.output
# $a/scripts/fimo --norc --text --verbosity 1 --no-qvalue $a/pwm/HOCOMOCOv11_core_HUMAN_mono_meme_format.meme $b/$1/$1.alt.fa >$b/$1/$1.alt.output
# if [ ! -s $b/$1/$1.ref.output ];then
# cat $a/head_out  >>$b/$1/$1.ref.output
# fi
# if [ ! -s $b/$1/$1.alt.output ];then
# cat $a/head_out  >>$b/$1/$1.alt.output
# fi
# /home/caow/miniconda3/envs/mnvtfdb/bin/Rscript $a/scripts/merge_v2.r $b/$1/$1.ref.output $b/$1/$1.alt.output $b/$1/$1.mergeout
# grep -v None $b/$1/$1.mergeout >$b/$1/$1.mergeout_f1
# /home/caow/miniconda3/envs/mnvtfdb/bin/python $a/scripts/filter_promoter1.py $a/resources/hg19_refseq_NMgene_promoter.sorted.bed $b/$1/$1.mergeout_f1 $b/$1/$1.mergeout_f2
# cat $a/head1 $b/$1/$1.mergeout_f2 >$b/$1/$1.mergeout_f3
# /home/caow/miniconda3/envs/mnvtfdb/bin/Rscript $a/scripts/merge_f.r $b/$1/$1.mergeout_f3 $b/$1/$1_out1

$a/scripts/fimo --norc --text --verbosity 1 --no-qvalue $a/pwm/JASPAR2022_CORE_vertebrates_non-redundant_pfms_meme.txt $b/$1/$1.ref.fa >$b/$1/$1.ref.output1
$a/scripts/fimo --norc --text --verbosity 1 --no-qvalue $a/pwm/JASPAR2022_CORE_vertebrates_non-redundant_pfms_meme.txt $b/$1/$1.alt.fa >$b/$1/$1.alt.output1
if [ ! -s $b/$1/$1.ref.output1 ];then
cat $a/head_out  >>$b/$1/$1.ref.output1
fi
if [ ! -s $b/$1/$1.alt.output1 ];then
cat $a/head_out  >>$b/$1/$1.alt.output1
fi
/home/caow/miniconda3/envs/mnvtfdb/bin/Rscript $a/scripts/merge_v2j.r $b/$1/$1.ref.output1 $b/$1/$1.alt.output1 $b/$1/$1.mergeout1
grep -v None $b/$1/$1.mergeout1 >$b/$1/$1.mergeout1_f1
/home/caow/miniconda3/envs/mnvtfdb/bin/python $a/scripts/filter_promoter1.py $a/resources/hg19_refseq_NMgene_promoter.sorted.bed $b/$1/$1.mergeout1_f1 $b/$1/$1.mergeout1_f2
cat $a/head1 $b/$1/$1.mergeout1_f2 >$b/$1/$1.mergeout1_f3
/home/caow/miniconda3/envs/mnvtfdb/bin/Rscript $a/scripts/merge_f.r $b/$1/$1.mergeout1_f3 $b/$1/$1_out2

# sed -i '1d' $b/$1/$1_out2
# cat $b/$1/$1_out1 $b/$1/$1_out2 >$b/$1/$1_out
cat $b/$1/$1_out2 >$b/$1/$1_out
